package com.dc.project.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author Enzo
 * @date 2020-7-8
 */
@EnableTransactionManagement
@Configuration
@MapperScan({"com.dc.base.mapper", "com.dc.project.demo.mapper", "com.dc.project.core.mapper", "com.dc.base.dynamic.mapper"})
public class MyBatisPlusConfig {

    /**
     * 乐观锁插件
     */
    @Bean
    public MybatisPlusInterceptor myOptimisticLockerInnerInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
        return interceptor;
    }
}